<template>
  <div class="app-container">
      <div class="filter-container">
        <el-button class="filter-item" type="primary" v-waves icon="el-icon-plus" @click="handleUpdate(null)">添加</el-button>        
        

        <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">搜索</el-button>
        <el-button class="filter-item" type="primary"  v-waves icon="el-icon-document" @click="exportExcelFile">导出</el-button>
      </div>
      <el-table :data="list" @sort-change="sortChange" v-loading="listLoading" element-loading-text="给我一点时间" border fit highlight-current-row
      style="width: 100%">
        <el-table-column align="center" type="index" label="序号" width="80">
        </el-table-column>

        
        
        <el-table-column  prop="invoiceNo" align="center" label="发票号码" width="120">
          <template slot-scope="scope">
            <span>{{scope.row.invoiceNo}}</span>
          </template>
        </el-table-column>
        
        
        <el-table-column  prop="status" align="center" label="发票状态" width="120">
          <template slot-scope="scope">
            <span>{{scope.row.status}}</span>
          </template>
        </el-table-column>
        
        
        <el-table-column  prop="source" align="center" label="发票来源" width="120">
          <template slot-scope="scope">
            <span>{{scope.row.source}}</span>
          </template>
        </el-table-column>
        
        
        <el-table-column  prop="createTime" align="center" label="开票时间" width="120">
          <template slot-scope="scope">
            <span>{{scope.row.createTime}}</span>
          </template>
        </el-table-column>
        
        
        <el-table-column  prop="telephone" align="center" label="手机号" width="120">
          <template slot-scope="scope">
            <span>{{scope.row.telephone}}</span>
          </template>
        </el-table-column>
        
        
        <el-table-column  prop="email" align="center" label="邮箱" width="120">
          <template slot-scope="scope">
            <span>{{scope.row.email}}</span>
          </template>
        </el-table-column>
        
        
        <el-table-column  prop="header" align="center" label="发票抬头" width="120">
          <template slot-scope="scope">
            <span>{{scope.row.header}}</span>
          </template>
        </el-table-column>
        
        
        <el-table-column  prop="taxpayerNo" align="center" label="纳税人识别编号" width="120">
          <template slot-scope="scope">
            <span>{{scope.row.taxpayerNo}}</span>
          </template>
        </el-table-column>
        
        
        <el-table-column  prop="oilStationNo" align="center" label="油站编号" width="120">
          <template slot-scope="scope">
            <span>{{scope.row.oilStationNo}}</span>
          </template>
        </el-table-column>
        
        
        <el-table-column  prop="serialNo" align="center" label="流水号" width="120">
          <template slot-scope="scope">
            <span>{{scope.row.serialNo}}</span>
          </template>
        </el-table-column>
        
        
        <el-table-column  prop="businessDate" align="center" label="营业日期" width="120">
          <template slot-scope="scope">
            <span>{{scope.row.businessDate}}</span>
          </template>
        </el-table-column>
        
        
        <el-table-column  prop="POSID" align="center" label="POS_ID" width="120">
          <template slot-scope="scope">
            <span>{{scope.row.POSID}}</span>
          </template>
        </el-table-column>
        
        
        <el-table-column align="center" label="操作" width="200" class-name="small-padding">
          <template slot-scope="scope">
            <el-button type="primary" size="mini" @click="handleUpdate(scope.row)">修改</el-button>          
            <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination-container">
      <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="params.page"
        :page-sizes="[10,20,30,50]" :page-size="params.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
      </el-pagination>
    </div>

    <el-dialog :title="isEditing?'修改':'添加'" :visible.sync="dialogFormVisible">
      <el-form class="dialog-form" :rules="rules" ref="dataForm" :model="temp" label-position="left" label-width="120px">
        
        <el-form-item label="发票号码" prop="invoiceNo">          
            
                                  
                  <el-input v-model="temp.invoiceNo" placeholder="发票号码"></el-input>
                
            
        </el-form-item>         
        
        <el-form-item label="发票状态" prop="status">          
            
                                  
                  <el-input v-model="temp.status" placeholder="发票状态"></el-input>
                
            
        </el-form-item>         
        
        <el-form-item label="发票来源" prop="source">          
            
                                  
                  <el-input v-model="temp.source" placeholder="发票来源"></el-input>
                
            
        </el-form-item>         
        
        <el-form-item label="手机号" prop="telephone">          
            
                                  
                  <el-input v-model="temp.telephone" placeholder="手机号"></el-input>
                
            
        </el-form-item>         
        
        <el-form-item label="邮箱" prop="email">          
            
                                  
                  <el-input v-model="temp.email" placeholder="邮箱"></el-input>
                
            
        </el-form-item>         
        
        <el-form-item label="发票抬头" prop="header">          
            
                                  
                  <el-input v-model="temp.header" placeholder="发票抬头"></el-input>
                
            
        </el-form-item>         
        
        <el-form-item label="纳税人识别编号" prop="taxpayerNo">          
            
                                  
                  <el-input v-model="temp.taxpayerNo" placeholder="纳税人识别编号"></el-input>
                
            
        </el-form-item>         
        
        <el-form-item label="油站编号" prop="oilStationNo">          
            
                                  
                  <el-input v-model="temp.oilStationNo" placeholder="油站编号"></el-input>
                
            
        </el-form-item>         
        
        <el-form-item label="流水号" prop="serialNo">          
            
                                  
                  <el-input v-model="temp.serialNo" placeholder="流水号"></el-input>
                
            
        </el-form-item>         
        
        <el-form-item label="营业日期" prop="businessDate">          
            
                                  
                  <el-input v-model="temp.businessDate" placeholder="营业日期"></el-input>
                
            
        </el-form-item>         
        
        <el-form-item label="POS_ID" prop="POSID">          
            
                                  
                  <el-input v-model="temp.POSID" placeholder="POS_ID"></el-input>
                
            
        </el-form-item>         
                         
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取消</el-button>
        <el-button type="primary" :loading="submiting" @click="submitFormAction">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>

export default {
  data() {
    return {
      temp:{
          
          id:'',
          
          invoiceNo:'',
          
          status:'',
          
          source:'',
          
          telephone:'',
          
          email:'',
          
          header:'',
          
          taxpayerNo:'',
          
          oilStationNo:'',
          
          serialNo:'',
          
          businessDate:'',
          
          POSID:'',
          
      },
      
      rules: {
        
        invoiceNo: [
          
          { required: true, message: "发票号码不能为空", trigger: "change",max:30}
          
        ],        
        
        status: [
          
          { required: true, message: "发票状态不能为空", trigger: "change"}
          
        ],        
        
        source: [
          
          { required: true, message: "发票来源不能为空", trigger: "change",max:60}
          
        ],        
        
        telephone: [
          
          { required: true, message: "手机号不能为空", trigger: "change",max:11}
          
        ],        
        
        email: [
          
          { required: true, message: "邮箱不能为空", trigger: "change",max:30}
          
        ],        
        
        header: [
          
          { required: true, message: "发票抬头不能为空", trigger: "change",max:600}
          
        ],        
        
        taxpayerNo: [
          
          { required: true, message: "纳税人识别编号不能为空", trigger: "change",max:60}
          
        ],        
        
        oilStationNo: [
          
          { required: true, message: "油站编号不能为空", trigger: "change",max:60}
          
        ],        
        
        serialNo: [
          
          { required: true, message: "流水号不能为空", trigger: "change",max:60}
          
        ],        
        
        businessDate: [
          
          { required: true, message: "营业日期不能为空", trigger: "change"}
          
        ],        
        
        POSID: [
          
          { required: true, message: "POS_ID不能为空", trigger: "change",max:60}
          
        ],        
        
      }
    };
  },
  created() {
    this.init("invoice",1).loadData();

    

    
  },
  filters: {

  },
  methods: {
    exportExcelFile() {
      this.exportExcel({
        title: "电子发票管理",
        fields: [
          
            
            {field:'invoiceNo',title:'发票号码'}
          
            ,
            {field:'status',title:'发票状态'}
          
            ,
            {field:'source',title:'发票来源'}
          
            ,
            {field:'createTime',title:'开票时间'}
          
            ,
            {field:'telephone',title:'手机号'}
          
            ,
            {field:'email',title:'邮箱'}
          
            ,
            {field:'header',title:'发票抬头'}
          
            ,
            {field:'taxpayerNo',title:'纳税人识别编号'}
          
            ,
            {field:'oilStationNo',title:'油站编号'}
          
            ,
            {field:'serialNo',title:'流水号'}
          
            ,
            {field:'businessDate',title:'营业日期'}
          
            ,
            {field:'POSID',title:'POS_ID'}
          
        ]
      }).then(info => {
        this.openWin(info);        
      });
    }
  }
};
</script>
